﻿using JsonConversion;
using Newtonsoft.Json;
using RTracker.Models.Common;
using RTracker.Models.ErrorLog;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;

namespace RTracker.Areas.Recruitment.Models.DriveRoundType
{
    public class MDriveRoundType
    {
        /// static variable RowSize from config settings to get list of this row size.
        public static int nRowSize = Convert.ToInt32(ConfigurationManager.AppSettings["TotalRecordsInListCalling"]);

        /// <summary>
        /// This method is used to create a user in the database.
        /// </summary>
        /// <param name="objCAuthenticationContext">This object contains information about user's authentication context.</param>
        /// <param name="objCDriveRoundType">This object contains details of the user.</param>
        /// <returns>CStatus which is an object that contain transaction details</returns>
        public CStatus CreateDriveRoundType(CAuthenticationContext objCAuthenticationContext, ref CDriveRoundType objCDriveRoundType)
        {
            CStatus oCStatus = new CStatus();


            using (SqlConnection con = new SqlConnection(CCommonCollection.ConnectionString))
            {
                try
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand("r_create_drive_round_type_procedure", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    //cmd.Parameters.Add("@CallingId", SqlDbType.Int).Value = objCDriveRoundType.DriveRoundTypeId;
                    cmd.Parameters.Add("@drive_round_type_name", SqlDbType.NVarChar).Value = objCDriveRoundType.DriveRoundTypeName;
                    cmd.Parameters.Add("@drive_round_type_desc", SqlDbType.NChar).Value = objCDriveRoundType.DriveRoundTypeDesc;
                    cmd.Parameters.Add("@drive_round_type_id", SqlDbType.NVarChar).Value = objCDriveRoundType.DriveRoundTypeId;
                    //cmd.Parameters.Add("@DriveRoundType_logo", SqlDbType.NVarChar).Value = objCDriveRoundType.DriveRoundTypeLogo;
                    //cmd.Parameters.Add("@website", SqlDbType.NVarChar).Value = objCDriveRoundType.Website;
                    //cmd.Parameters.Add("@industry", SqlDbType.NVarChar).Value = objCDriveRoundType.Industry;
                    //cmd.Parameters.Add("@DriveRoundType_manager", SqlDbType.NVarChar).Value = objCDriveRoundType.DriveRoundTypeManager;
                    //cmd.Parameters.Add("@contract_doc", SqlDbType.VarBinary).Value = null;
                    cmd.Parameters.Add("@created_by", SqlDbType.Int).Value = objCDriveRoundType.CreatedBy;
                    cmd.Parameters.Add("@idOut", SqlDbType.Int).Value = null;
                    cmd.Parameters["@idOut"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@error", SqlDbType.Int).Value = null;
                    cmd.Parameters["@error"].Direction = ParameterDirection.Output;

                    cmd.ExecuteNonQuery();

                    if (Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()) > 0)
                    {
                        oCStatus.Success = true;
                        oCStatus.StatusDetails = CAppConstants.SessionSuccess;
                    }
                    else
                    {
                        oCStatus.Success = false;
                        oCStatus.StatusDetails = Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()).DbError();
                        //oCStatus.StatusDetails = CAppErrorsConstants.SomethingWentWrong;
                    }
                }
                catch (Exception ex)
                {
                    oCStatus.Success = false;
                    oCStatus.StatusDetails = ex.Message;
                }
            }


            return oCStatus;
        }

        /// <summary>
        /// This method is used to delete a user in the database.
        /// </summary>
        /// <param name="objCAuthenticationContext">This object contains information about user's authentication context.</param>
        /// <param name="objCDriveRoundType">This object contains details of the user.</param>
        /// <returns>CStatus which is an object that contain transaction details.</returns>
        public CStatus DeleteDriveRoundType(CAuthenticationContext objCAuthenticationContext, ref CDriveRoundType objCDriveRoundType)
        {
            CStatus oCStatus = new CStatus();

            using (SqlConnection con = new SqlConnection(CCommonCollection.ConnectionString))
            {
                try
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand("r_delete_drive_round_type_procedure", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@created_by", SqlDbType.Int).Value = objCDriveRoundType.CreatedBy;
                    cmd.Parameters.Add("@drive_round_type_ids", SqlDbType.NVarChar).Value = objCDriveRoundType.DriveRoundTypeIds;

                    cmd.Parameters.Add("@idOut", SqlDbType.Int).Value = null;
                    cmd.Parameters["@idOut"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@error", SqlDbType.Int).Value = null;
                    cmd.Parameters["@error"].Direction = ParameterDirection.Output;

                    cmd.ExecuteNonQuery();

                    if (Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()) > 0)
                    {
                        oCStatus.Success = true;
                        oCStatus.StatusDetails = CAppConstants.SessionSuccess;
                    }
                    else
                    {
                        oCStatus.Success = false;
                        oCStatus.StatusDetails = Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()).DbError();
                        //oCStatus.StatusDetails = CAppErrorsConstants.SomethingWentWrong;
                    }
                }
                catch (Exception ex)
                {
                    oCStatus.Success = false;
                    oCStatus.StatusDetails = ex.Message;
                }
            }


            return oCStatus;
        }

        /// <summary>
        /// This method is used to update the user's detail in the database.
        /// </summary>
        /// <param name="objCAuthenticationContext">This object contains information about user's authentication context.</param>
        /// <param name="objCDriveRoundType">This object contains details of the user.</param>
        /// <returns>CStatus which is an object that contain transaction details.</returns>
        public CStatus UpdateDriveRoundType(CAuthenticationContext objCAuthenticationContext, ref CDriveRoundType objCDriveRoundType)
        {
            CStatus oCStatus = new CStatus();

            using (SqlConnection con = new SqlConnection(CCommonCollection.ConnectionString))
            {
                try
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand("r_update_drive_round_type_procedure", con);
                    cmd.CommandType = CommandType.StoredProcedure;


                    cmd.Parameters.Add("@drive_round_type_name", SqlDbType.NVarChar).Value = objCDriveRoundType.DriveRoundTypeName;
                    cmd.Parameters.Add("@drive_round_type_desc", SqlDbType.NChar).Value = objCDriveRoundType.DriveRoundTypeDesc;
                    cmd.Parameters.Add("@drive_round_type_id", SqlDbType.NVarChar).Value = objCDriveRoundType.DriveRoundTypeId;
                    //cmd.Parameters.Add("@contact_address", SqlDbType.Int).Value = objCDriveRoundType.ContactAddress;
                    //cmd.Parameters.Add("@DriveRoundType_logo ", SqlDbType.Int).Value = objCDriveRoundType.DriveRoundTypeLogo;
                    //cmd.Parameters.Add("@website", SqlDbType.NVarChar).Value = objCDriveRoundType.Website;
                    //cmd.Parameters.Add("@industry", SqlDbType.Int).Value = objCDriveRoundType.Industry;
                    //cmd.Parameters.Add("@DriveRoundType_manager", SqlDbType.Int).Value = objCDriveRoundType.DriveRoundTypeManager;
                    //cmd.Parameters.Add("@contract_doc", SqlDbType.Int).Value = null;
                    cmd.Parameters.Add("@created_by", SqlDbType.Int).Value = objCDriveRoundType.CreatedBy;








                    //cmd.Parameters.Add("@Vacancy", SqlDbType.Int).Value = objCDriveRoundType.Vacancy;
                    //cmd.Parameters.Add("@Candidate", SqlDbType.Int).Value = objCDriveRoundType.Candidate;
                    //cmd.Parameters.Add("@callTimestamp", SqlDbType.DateTime).Value = objCDriveRoundType.callTimestamp;
                    //cmd.Parameters.Add("@callstatus", SqlDbType.Int).Value = objCDriveRoundType.callstatus;
                    //cmd.Parameters.Add("@logon_password", SqlDbType.NVarChar).Value = objCDriveRoundType.LogonPassword;
                    //cmd.Parameters.Add("@last_successful_logout_timestamp", SqlDbType.DateTime).Value = objCDriveRoundType.LastSuccessfulLogoutTimestamp;
                    //cmd.Parameters.Add("@logon_failure_count", SqlDbType.Int).Value = objCDriveRoundType.LogonFailureCount;
                    //cmd.Parameters.Add("@is_system_generated", SqlDbType.Bit).Value = objCDriveRoundType.IsSystemGenerated;


                    cmd.Parameters.Add("@idOut", SqlDbType.Int).Value = null;
                    cmd.Parameters["@idOut"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@error", SqlDbType.Int).Value = null;
                    cmd.Parameters["@error"].Direction = ParameterDirection.Output;

                    cmd.ExecuteNonQuery();

                    if (Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()) > 0)
                    {
                        oCStatus.Success = true;
                        oCStatus.StatusDetails = CAppConstants.SessionSuccess;
                    }
                    else
                    {
                        oCStatus.Success = false;
                        oCStatus.StatusDetails = Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()).DbError();
                        //oCStatus.StatusDetails = CAppErrorsConstants.SomethingWentWrong;
                    }
                }
                catch (Exception ex)
                {
                    oCStatus.Success = false;
                    oCStatus.StatusDetails = ex.Message;
                }
            }

            return oCStatus;
        }

        /// <summary>
        /// This method is used to get the user's detail in the database.
        /// </summary>
        /// <param name="objCAuthenticationContext">This object contains information about user's authentication context.</param>
        /// <param name="objCDriveRoundType">This object contains details of the user.</param>
        /// <returns>CStatus which is an object that contain transaction details.</returns>
        public CStatus GetDriveRoundTypeDetail(CAuthenticationContext objCAuthenticationContext, ref CDriveRoundType objCDriveRoundType)
        {
            CStatus oCStatus = new CStatus();
            using (SqlConnection con = new SqlConnection(CCommonCollection.ConnectionString))
            {
                try
                {
                    SqlCommand cmd = new SqlCommand("r_get_drive_round_type_detail_procedure", con);
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add("@drive_round_type_id", SqlDbType.Int).Value = objCDriveRoundType.DriveRoundTypeId;
                    //cmd.Parameters.Add("@idOut", SqlDbType.Int).Value = null;
                    //cmd.Parameters["@idOut"].Direction = ParameterDirection.Output;

                    SqlDataAdapter adp = new SqlDataAdapter(cmd);

                    DataTable dt = new DataTable();

                    int rowsAffected = adp.Fill(dt);

                    if (rowsAffected > 0)
                    {
                        objCDriveRoundType = dt.ConvertToListFromDataTableDriveRoundType()[0];
                    }

                    //if (Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()) > 0)
                    //{
                    //    oCStatus.Success = true;
                    //    oCStatus.StatusDetails = CAppConstants.DetailSuccess;
                    //}
                    //else
                    //{
                    //    oCStatus.Success = false;
                    //    oCStatus.StatusDetails = Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()).DbError();
                    //}
                }
                catch (Exception ex)
                {
                    oCStatus.Success = false;
                    oCStatus.StatusDetails = ex.Message;
                }
            }
            return oCStatus;
        }

        /// <summary>
        /// Sets the softlock on the record whose Id is passed.
        /// </summary>
        /// <param name="objCAuthenticationContext">This object contains information about user's authentication context.</param>
        /// <param name="objCDriveRoundType">This object contains details of the user.</param>
        /// <returns>CStatus which is an object that contain transaction details.</returns>
        public CStatus SetDriveRoundTypeSoftLock(CAuthenticationContext objCAuthenticationContext, CDriveRoundType objCDriveRoundType)
        {
            CStatus oCStatus = new CStatus();

            using (SqlConnection con = new SqlConnection(CCommonCollection.ConnectionString))
            {
                try
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand("r_set_drive_round_type_soft_lock_procedure", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@drive_round_type_id", SqlDbType.Int).Value = objCDriveRoundType.DriveRoundTypeId;
                    cmd.Parameters.Add("@created_by", SqlDbType.Int).Value = objCDriveRoundType.CreatedBy;

                    cmd.Parameters.Add("@idOut", SqlDbType.Int).Value = null;
                    cmd.Parameters["@idOut"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@error", SqlDbType.Int).Value = null;
                    cmd.Parameters["@error"].Direction = ParameterDirection.Output;

                    cmd.ExecuteNonQuery();

                    if (Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()) > 0)
                    {
                        oCStatus.Success = true;
                        oCStatus.StatusDetails = CAppConstants.SessionSuccess;
                    }
                    else
                    {
                        oCStatus.Success = false;
                        oCStatus.StatusDetails = Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()).DbError();
                        //oCStatus.StatusDetails = CAppErrorsConstants.SomethingWentWrong;
                    }
                }
                catch (Exception ex)
                {
                    oCStatus.Success = false;
                    oCStatus.StatusDetails = ex.Message;
                }
            }


            return oCStatus;
        }

        /// <summary>
        /// Sets the hardlock on the record whose Id is passed.
        /// </summary>
        /// <param name="objCAuthenticationContext">This object contains information about user's authentication context.</param>
        /// <param name="objCDriveRoundType">This object contains details of the user.</param>
        /// <returns>CStatus which is an object that contain transaction details.</returns>
        public CStatus SetDriveRoundTypeHardLock(CAuthenticationContext objCAuthenticationContext, CDriveRoundType objCDriveRoundType)
        {
            CStatus oCStatus = new CStatus();

            using (SqlConnection con = new SqlConnection(CCommonCollection.ConnectionString))
            {
                try
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand("r_set_drive_round_type_hard_lock_procedure", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@drive_round_type_id", SqlDbType.Int).Value = objCDriveRoundType.DriveRoundTypeId;
                    cmd.Parameters.Add("@created_by", SqlDbType.Int).Value = objCDriveRoundType.CreatedBy;

                    cmd.Parameters.Add("@idOut", SqlDbType.Int).Value = null;
                    cmd.Parameters["@idOut"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@error", SqlDbType.Int).Value = null;
                    cmd.Parameters["@error"].Direction = ParameterDirection.Output;

                    cmd.ExecuteNonQuery();

                    if (Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()) > 0)
                    {
                        oCStatus.Success = true;
                        oCStatus.StatusDetails = CAppConstants.SessionSuccess;
                    }
                    else
                    {
                        oCStatus.Success = false;
                        oCStatus.StatusDetails = Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()).DbError();
                        //oCStatus.StatusDetails = CAppErrorsConstants.SomethingWentWrong;
                    }
                }
                catch (Exception ex)
                {
                    oCStatus.Success = false;
                    oCStatus.StatusDetails = ex.Message;
                }
            }


            return oCStatus;
        }

        /// <summary>
        /// Releases the softlock on the record whose Id is passed.
        /// </summary>
        /// <param name="objCAuthenticationContext">This object contains information about user's authentication context.</param>
        /// <param name="objCDriveRoundType">This object contains details of the user.</param>
        /// <returns>CStatus which is an object that contain transaction details.</returns>
        public CStatus ReleaseDriveRoundTypeSoftLock(CAuthenticationContext objCAuthenticationContext, CDriveRoundType objCDriveRoundType)
        {
            CStatus oCStatus = new CStatus();

            using (SqlConnection con = new SqlConnection(CCommonCollection.ConnectionString))
            {
                try
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand("r_release_drive_round_type_soft_lock_procedure", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@drive_round_type_id", SqlDbType.Int).Value = objCDriveRoundType.DriveRoundTypeId;
                    cmd.Parameters.Add("@created_by", SqlDbType.Int).Value = objCDriveRoundType.CreatedBy;

                    cmd.Parameters.Add("@idOut", SqlDbType.Int).Value = null;
                    cmd.Parameters["@idOut"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@error", SqlDbType.Int).Value = null;
                    cmd.Parameters["@error"].Direction = ParameterDirection.Output;

                    cmd.ExecuteNonQuery();

                    if (Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()) > 0)
                    {
                        oCStatus.Success = true;
                        oCStatus.StatusDetails = CAppConstants.SessionSuccess;
                    }
                    else
                    {
                        oCStatus.Success = false;
                        oCStatus.StatusDetails = Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()).DbError();
                        //oCStatus.StatusDetails = CAppErrorsConstants.SomethingWentWrong;
                    }
                }
                catch (Exception ex)
                {
                    oCStatus.Success = false;
                    oCStatus.StatusDetails = ex.Message;
                }
            }


            return oCStatus;
        }

        /// <summary>
        /// Releases the hardlock on the record whose Id is passed.
        /// </summary>
        /// <param name="objCAuthenticationContext">This object contains information about user's authentication context.</param>
        /// <param name="objCDriveRoundType">This object contains details of the user.</param>
        /// <returns>CStatus which is an object that contain transaction details.</returns>
        public CStatus ReleaseDriveRoundTypeHardLock(CAuthenticationContext objCAuthenticationContext, CDriveRoundType objCDriveRoundType)
        {
            CStatus oCStatus = new CStatus();

            using (SqlConnection con = new SqlConnection(CCommonCollection.ConnectionString))
            {
                try
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand("r_release_drive_round_type_hard_lock_procedure", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@drive_round_type_id", SqlDbType.Int).Value = objCDriveRoundType.DriveRoundTypeId;
                    cmd.Parameters.Add("@created_by", SqlDbType.Int).Value = objCDriveRoundType.CreatedBy;

                    cmd.Parameters.Add("@idOut", SqlDbType.Int).Value = null;
                    cmd.Parameters["@idOut"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@error", SqlDbType.Int).Value = null;
                    cmd.Parameters["@error"].Direction = ParameterDirection.Output;

                    cmd.ExecuteNonQuery();

                    if (Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()) > 0)
                    {
                        oCStatus.Success = true;
                        oCStatus.StatusDetails = CAppConstants.SessionSuccess;
                    }
                    else
                    {
                        oCStatus.Success = false;
                        oCStatus.StatusDetails = Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()).DbError();
                        //oCStatus.StatusDetails = CAppErrorsConstants.SomethingWentWrong;
                    }
                }
                catch (Exception ex)
                {
                    oCStatus.Success = false;
                    oCStatus.StatusDetails = ex.Message;
                }
            }


            return oCStatus;
        }

        /// <summary>
        ///  This function is used to get complete Calling list
        /// </summary>
        /// <returns>List of type CDriveRoundType</returns>
        public GDriveRoundType GetDriveRoundTypeGridList(CDriveRoundType objCDriveRoundType, CAuthenticationContext objCAuthenticationContext)
        {
            GDriveRoundType objGDriveRoundType = new GDriveRoundType();
            int nTotalRecords = 0;
            int nCurrentRowSize = nRowSize;

            if (objCDriveRoundType.RowSize != 0)
            {
                nCurrentRowSize = objCDriveRoundType.RowSize;
            }
            using (SqlConnection con = new SqlConnection(CCommonCollection.ConnectionString))
            {
                try
                {
                    SqlCommand cmd = new SqlCommand("r_get_drive_round_type_paging_list_procedure", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@drive_round_type_id", SqlDbType.Int).Value = objCDriveRoundType.DriveRoundTypeId;
                    cmd.Parameters.Add("@organization_id", SqlDbType.Int).Value = objCDriveRoundType.OrganizationId;
                    cmd.Parameters.Add("@page_number", SqlDbType.Int).Value = objCDriveRoundType.PageNumber;
                    cmd.Parameters.Add("@row_size", SqlDbType.Int).Value = nCurrentRowSize;
                    cmd.Parameters.Add("@sort_on", SqlDbType.VarChar).Value = objCDriveRoundType.SortOn;
                    cmd.Parameters.Add("@sort_type", SqlDbType.VarChar).Value = objCDriveRoundType.SortType;
                    cmd.Parameters.Add("@search", SqlDbType.VarChar).Value = objCDriveRoundType.Search;
                    cmd.Parameters.Add("@searchon", SqlDbType.VarChar).Value = objCDriveRoundType.SearchOn;
                    cmd.Parameters.Add("@idOut", SqlDbType.Int).Value = null;
                    cmd.Parameters["@idOut"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@error", SqlDbType.Int).Value = null;
                    cmd.Parameters["@error"].Direction = ParameterDirection.Output;
                    SqlDataAdapter adp = new SqlDataAdapter(cmd);

                    DataTable dt = new DataTable();

                    int rowsAffected = adp.Fill(dt);

                    objGDriveRoundType.Paging = new CPaging();
                    if (rowsAffected > 0)
                    {
                        //objGDriveRoundType.LstDriveRoundType
                        objGDriveRoundType.LstDriveRoundType = dt.ConvertToListFromDataTableDriveRoundType();
                        objGDriveRoundType.LstDriveRoundType[0].PageNumber = int.Parse(cmd.Parameters["@idOut"].Value.ToString());
                        objGDriveRoundType.Paging.PageNumber = objGDriveRoundType.LstDriveRoundType[0].PageNumber;
                    }
                    else
                    {
                        objGDriveRoundType.LstDriveRoundType = null;
                    }


                    nTotalRecords = int.Parse(cmd.Parameters["@error"].Value.ToString());

                    objGDriveRoundType.Status = new CStatus();

                    if (nTotalRecords < 0)
                    {
                        objGDriveRoundType.Status.Success = false;
                        objGDriveRoundType.Status.StatusDetails = nTotalRecords.DbError();
                    }
                    else
                    {
                        objGDriveRoundType.Paging.TotalRecordsCount = nTotalRecords;
                        objGDriveRoundType.Paging.PageSize = nCurrentRowSize;

                        objGDriveRoundType.Status.Success = true;
                        objGDriveRoundType.Status.StatusDetails = "success";
                    }



                }
                catch (Exception ex)
                {
                    objGDriveRoundType.Status = new CStatus();
                    objGDriveRoundType.Status.Success = false;
                    objGDriveRoundType.Status.StatusDetails = ex.Message;
                }
            }
            return objGDriveRoundType;
        }



    }
    public static class MDriveRoundTypeConverter
    {
        private static Boolean ColContain(DataTable dt, DataRow dtRow, string colname)
        {
            Boolean res = false;
            if (dt.Columns.Contains(colname) && dtRow[colname] != DBNull.Value)
            {
                res = true;
            }
            return res;
        }
        public static List<CDriveRoundType> ConvertToListFromDataTableDriveRoundType(this DataTable dt)
        {

            List<CDriveRoundType> lstTemp = new List<CDriveRoundType>();

            foreach (DataRow dtRow in dt.Rows)
            {
                CDriveRoundType objTemp = new CDriveRoundType();

                if (ColContain(dt, dtRow, "drive_round_type_id"))
                    objTemp.DriveRoundTypeId = Convert.ToInt32(dtRow["drive_round_type_id"]);
                if (ColContain(dt, dtRow, "organization_id"))
                    objTemp.OrganizationId = Convert.ToInt32(dtRow["organization_id"]);
                if (ColContain(dt, dtRow, "drive_round_type_name"))
                    objTemp.DriveRoundTypeName = Convert.ToString(dtRow["drive_round_type_name"]);
                if (ColContain(dt, dtRow, "drive_round_type_desc"))
                    objTemp.DriveRoundTypeDesc = Convert.ToString(dtRow["drive_round_type_desc"]);

                if (ColContain(dt, dtRow, "is_soft_locked"))
                    objTemp.IsSoftLocked = Convert.ToBoolean(dtRow["is_soft_locked"]);
                if (ColContain(dt, dtRow, "soft_locked_by"))
                    objTemp.SoftLockedBy = Convert.ToInt32(dtRow["soft_locked_by"]);
                if (ColContain(dt, dtRow, "soft_lock_timestamp"))
                    objTemp.SoftLockTimestamp = Convert.ToDateTime(dtRow["soft_lock_timestamp"]);
                if (ColContain(dt, dtRow, "is_hard_locked"))
                    objTemp.IsHardLocked = Convert.ToBoolean(dtRow["is_hard_locked"]);
                if (ColContain(dt, dtRow, "hard_locked_by"))
                    objTemp.HardLockedBy = Convert.ToInt32(dtRow["hard_locked_by"]);
                if (ColContain(dt, dtRow, "hard_lock_timestamp"))
                    objTemp.HardLockTimestamp = Convert.ToDateTime(dtRow["hard_lock_timestamp"]);
                if (ColContain(dt, dtRow, "create_timestamp"))
                    objTemp.CreateTimestamp = Convert.ToDateTime(dtRow["create_timestamp"]);
                if (ColContain(dt, dtRow, "created_by"))
                    objTemp.CreatedBy = Convert.ToInt32(dtRow["created_by"]);
                if (ColContain(dt, dtRow, "modified_timestamp"))
                    objTemp.ModifiedTimestamp = Convert.ToDateTime(dtRow["modified_timestamp"]);
                if (ColContain(dt, dtRow, "modified_by"))
                    objTemp.ModifiedBy = Convert.ToInt32(dtRow["modified_by"]);
                if (ColContain(dt, dtRow, "delete_flag"))
                    objTemp.DeleteFlag = Convert.ToBoolean(dtRow["delete_flag"]);

                lstTemp.Add(objTemp);

            }
            return lstTemp;
        }
    }
}